#!/bin/sh
if [ $# -lt 1 -o $# -gt 2 ]; then
	echo "Usage:"
	echo "bench_svg.sh [OPTIONS] DIR"
	echo "Where OPTIONS are the options passed to esvg_bench"
	echo "Where DIR is the directory to read .svg files"
	exit 0
fi

if [ $# -gt 1 ]; then
	BENCH_OPT="$1"
	SRC="$2"
else
	SRC=$1
fi

MACHINE=`uname -p -m`
#echo $MACHINE
#echo "options = $BENCH_OPT"
for i in `find $SRC -name \*.svg -type f`; do
	svg=$i
	png="`basename $i`.png"

	#echo "Benchmarking file $svg" > /dev/stdout
	esvg_bench $BENCH_OPT $svg 2> /dev/null
	ret=$?
	if [ $ret -ne 0 ]; then
		echo "file $svg failed" > /dev/stderr
	fi
done

